//
//  QNShareImageTool.h
//  QNReuseTool
//
//  Created by rsh on 2019/10/15.
//  Copyright © 2019年 rsh. All rights reserved.
//

#import <UIKit/UIKit.h>

// MARK: 分享图片工具

@class QNShareElement,QNShareElementExt;

typedef NS_ENUM(NSUInteger, QNShareElementType) {
    QNShareElementTypeQRCode,
    QNShareElementTypeText,
    QNShareElementTypeImage
};

typedef void (^QNMakeImageCompleteHandler)(UIImage *image, NSError *error);

typedef void (^QNShareCompleteHandler)(UIActivityType type, BOOL completed, NSError *error);

@interface QNShareImageTool : NSObject

+ (instancetype)shared;

- (void)makeShareImageWithElements:(NSArray<QNShareElement *> *)elements complete:(QNMakeImageCompleteHandler)complete;

- (void)startShareWithImage:(UIImage *)shareImage complete:(QNShareCompleteHandler)complete;

@end


@interface QNShareElement : NSObject

@property (nonatomic, assign) QNShareElementType elementType;

@property (nonatomic, assign) BOOL isBackGround;

@property (nonatomic, assign) CGRect elementRect;

@property (nonatomic, copy) id elementValue;

@property (nonatomic, strong) QNShareElementExt *elementExt;

@end

@interface QNShareElementExt : NSObject

@property (nonatomic, strong) UIColor *elementColor;

@property (nonatomic, strong) UIFont *elementFont;

@property (nonatomic, strong) UIImage *placeholderImg;

@end

@interface UIImage (QNQRCode)

+ (UIImage *)QRCodeImageWithStr:(NSString *)str size:(CGSize)size;

@end
